<!--
 * @Author: weidewei
 * @Date: 2025-11-05 16:21:00
 * @LastEditors: weidewei
 * @LastEditTime: 2025-11-05 17:07:35
 * @Description: 
 * @FilePath: \2025-front-face\review-knowledge\20251105\复习科里化.html
-->
<script>
  function add(a, b, c) {
    return a + b + c;
  }

  function curry(fn, ...outerArgs) {
    return function (...innerArgs) {
      // 合并所有的参数
      let allArgs = [...outerArgs, ...innerArgs];
      // 参数收集够了
      if (allArgs.length >= fn.length) {
        return fn.apply(this, allArgs);
      } else {
        return curry(fn, ...allArgs);
      }
    };
  }

  

  const curryFn = curry(add);
  console.log("curryFnnn", curryFn(1)(2)(3));
  console.log("curryFnnn", curryFn(1)(2, 3));
  console.log("curryFnnn", curryFn(1, 2)(3));
  console.log("curryFnnn", curryFn(1, 2, 3));
</script>
